Skip to content

Conversation

@galak
Copy link
Contributor

@galak galak commented Oct 26, 2021

No description provided.

galak added 3 commits October 26, 2021 12:37
Add initial version for NXP Kinetis based SoCs.

Signed-off-by: Kumar Gala <[email protected]>
Convert driver to utilize new pinctrl API.  Update devicetree
binding to require pinctrl-0 and pinctrl-names properties.

Signed-off-by: Kumar Gala <[email protected]>
Remove board specific calls to pinmux_pin_set() for UART as the
UART driver will now handle the pin configuration via the pinctrl
API.

Signed-off-by: Kumar Gala <[email protected]>
.mux = PORT_PCR_MUX(DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 1)) | \
(DT_PROP(node_id, bias_pull_up) & (PORT_PCR_PE_MASK | PORT_PCR_PS_MASK)) | \
(DT_PROP(node_id, bias_pull_down) & PORT_PCR_PS_MASK) | \
(DT_PROP(node_id, drive_open_drain) & PORT_PCR_ODE_MASK), \
Copy link

@jgediya jgediya Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PORT_PCR_ODE_MASK is 0x20, If DT_PROP(node_id, drive_open_drain) return true(1) then '&' of them (1 & 0x20) will be 0. Instead we want 5th bit to be set here. Isn't it? Should we write here (DT_PROP(node_id, drive_open_drain) << PORT_PCR_ODE_SHIFT)? If this is true, then same can be applied to other '&' operations as well.

.pin = DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 0), \
.mux = PORT_PCR_MUX(DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 1)) | \
(DT_PROP(node_id, bias_pull_up) & (PORT_PCR_PE_MASK | PORT_PCR_PS_MASK)) | \
(DT_PROP(node_id, bias_pull_down) & PORT_PCR_PS_MASK) | \
Copy link

@jgediya jgediya Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't PORT_PCR_PE_MASK be used for pull-down?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This should be (DT_PROP(node_id, bias_pull_down) & PORT_PCR_PE_MASK) |.

Comment on lines +6 to +9
/**
* @file
* Public APIs for pin control drivers
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed

Comment on lines +14 to +19
/**
* @brief Pin Controller Interface (NXP Kinetis)
* @defgroup pinctrl_interface_nxp_kinetis Pin Controller Interface
* @ingroup pinctrl_interface
* @{
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this file doesn't expose any public API this can likely be removed

compatible: "nxp,kinetis-uart"

include: uart-controller.yaml
include: [uart-controller.yaml, pinctrl-device.yaml]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: update binding description to mention pinctrl requirements, with some example.

uintptr_t reg)
{
for (uint8_t i = 0U; i < pin_cnt; i++) {
pins[i].port_reg->PCR[pins[i].pin] = pins[i].mux;
Copy link

@jgediya jgediya Oct 27, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some more valid bits in the PCR register, shouldn't this be read, clear lowest 16 bits, and '|' mux value operation? Maybe in some scenario, this can create problems?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which bits would you preserve here? The idea is that all these bits are controlled by the pinctrl driver based on the devicetree properties.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IRQC bits, which are currently configured by gpio_mcux.c driver for interrupt configuration

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. Right.

@zephyrbot zephyrbot added area: Build System area: UART Universal Asynchronous Receiver-Transmitter labels Oct 27, 2021
int pinctrl_configure_pins(const pinctrl_soc_pin_t *pins, uint8_t pin_cnt,
uintptr_t reg)
{
for (uint8_t i = 0U; i < pin_cnt; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (uint8_t i = 0U; i < pin_cnt; i++) {
uint8_t i;
for (i = 0U; i < pin_cnt; i++) {

.pin = DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 0), \
.mux = PORT_PCR_MUX(DT_PROP_BY_IDX(node_id, nxp_kinetis_port_pins, 1)) | \
(DT_PROP(node_id, bias_pull_up) & (PORT_PCR_PE_MASK | PORT_PCR_PS_MASK)) | \
(DT_PROP(node_id, bias_pull_down) & PORT_PCR_PS_MASK) | \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. This should be (DT_PROP(node_id, bias_pull_down) & PORT_PCR_PE_MASK) |.

@henrikbrixandersen
Copy link
Member

henrikbrixandersen commented Oct 27, 2021

@galak Looks like a good starting point. We will likely need to add a custom drive strength dts property for selecting between high and low drive strength (the common drive-strength property expects a value in mA), but that can come at a later point in time.

I have opened a PR for setting the drive strength through the GPIO API here, but the drive strength applies to all digital outputs (e.g. high drive strength for PWM modulation of an LED): #39766

@carlescufi carlescufi mentioned this pull request Oct 28, 2021
29 tasks
@henrikbrixandersen
Copy link
Member

@galak What are your plans for getting this ready? If you do not have the time, I'd like to pick it up and get it ready for merging.

@github-actions
Copy link

This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time.

@github-actions github-actions bot added the Stale label Jan 30, 2022
@dleach02 dleach02 removed the Stale label Feb 1, 2022
@dleach02
Copy link
Member

dleach02 commented Feb 1, 2022

@henrikbrixandersen, we are going to take this over as part of the larger transition of NXP parts to pinctrl. We have two alternative approaches for the RT platforms in #42238 and #41810 and plan on applying the adopted solution across the rest of the NXP platforms.

@dleach02
Copy link
Member

We are going to complete the Kinetis pintctrl change over with #43033. Many thanks to @galak for providing guidance.

@dleach02 dleach02 closed this Feb 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: Boards area: Build System area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree area: UART Universal Asynchronous Receiver-Transmitter platform: NXP NXP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants